package com.appkubes.mall.restful.application.goods.category.controller;

import com.appkubes.base.core.entity.vo.AppKeyVO;
import com.appkubes.cloud.config.params.paramValid.ParamValid;
import com.appkubes.common.Response;
import com.appkubes.mall.core.entity.MallGoodsCategory;
import com.appkubes.mall.restful.application.common.base.BaseController;
import com.appkubes.mall.restful.application.goods.category.service.CategoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Api("获取商品分类模块")
@RestController
@RequestMapping(value = "/categorys")
public class GoodsCategoryController extends BaseController {

    @Autowired
    CategoryService categoryService;

    @ApiOperation(value = "获取首页分类")
    @PostMapping("/getClassify")
    public Response getClassify(@RequestBody @ParamValid AppKeyVO appKeyVO) {
        List<MallGoodsCategory> mallGoodsCategoryList = categoryService.getGoodsCategory(appKeyVO, 1);
        List<MallGoodsCategory> regions = categoryService.getGoodsCategory(appKeyVO, 3);

        Map<String, List> map = new HashMap<>();
        map.put("main", mallGoodsCategoryList);
        map.put("regions", regions);
        return imgResponse(map);
    }
}
